﻿<!DOCTYPE html>
<html lang="en" style="background:#fff;">
<head>
    <base href="${basePath}">
    <#include "common/top.html"/>
</head>
<body style="background:#fff;">

<form class="layui-form layui-form-pamel" name="form1" id="form1" method="post">
    <div class="layui-form-item-dept">
        <input id="roleId" name="roleId" value="${roleId}" type="hidden">
        <ul id="apps">
        </ul>
    </div>
</form>
</body>
<script type="text/javascript">

    var form;
    layui.use(['form'], function () {
        form = layui.form;
        form.render();
        renderApp();
    });


    //刷新应用
    function renderApp() {
        $.ajax({
            url: "${basePath}system/app/getSysAppAll",
            data: {roleId:'${roleId}'},
            type: "POST",
            success: function (data) {
                $("#apps").empty();
                if (data.status == true) {
                    var apps = data.t;
                    for (var i = 0;i < apps.length;i++) {
                        $("#apps").append('<li style="float: left;width: 45%;">' +
                            '           <span>' +
                            '               <input type="checkbox" lay-skin="primary"  lay-filter="filter"' +
                            '                      lay-verify="title" name="appIds" value="'+apps[i].appId+'"' +
                            '                      title="'+apps[i].appName+'" ' + apps[i].checked + '>' +
                            '           </span>' +
                            '       </li>');
                    }
                    form.render();

                } else {
                    parent.layer.alert(data.msg);
                }
            }
        })
    }

    //保 存
    function save() {
        $.ajax({
            url: "${basePath}system/menu/saveRoleAppIds",
            data: $("#form1").serialize(),
            type: "POST",
            success: function (data) {
                if (data.status == true) {
                    layer.alert(data.msg, function (index) {
                        var index1 = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index1);
                        layer.close(index);
                    });
                } else {
                    parent.layer.alert(data.msg);
                }
            }
        })
    }
</script>
</html>
